package com.dao.impl;

import com.dao.DeptDao;
import com.entity.Dept;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class DeptDaoImpl extends BaseDao implements DeptDao {
    @Override
    public String getNameById(Integer id) {

        QueryRunner qr = getQueryRunner();
        String sql = "select deptname  from dept where id = ?";
        BeanHandler<Dept> handler = new BeanHandler<>(Dept.class);
        Dept dept = null;
        try {
            dept = qr.query(sql, handler, id);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return dept.getDeptname();
    }


}
